<template>
  <div class="parent">
    <echartsDom v-if="isShowEcharts" :width="width" :height="height" :option="option" />
    <div v-else>
      <px-empty :image-size="50" />
    </div>
  </div>
</template>

<script setup lang="ts">
import { reactive, toRefs, ref } from "vue";
import echartsDom from "./echartsDom.vue";
import { queryConsumeChartForDay } from "@/api/waterKanban";
const props = defineProps({
  width: {
    type: String,
    default: ""
  },
  height: {
    type: String,
    default: ""
  },
  color: {
    type: String,
    default: "#3B82F6"
  }
});
const isShowEcharts = ref(false);
const state = reactive({
  option: {}
});
const { option } = toRefs(state);

const getoptions = () => {
  isShowEcharts.value = true;
  option.value = {
    color: ["#3B82F6 ", "#39C670"],
    grid: {
      left: "20px",
      top: "40px",
      right: "10px",
      bottom: "10px",
      containLabel: true
    },
    legend: {
      x: "center"
    },
    tooltip: {
      trigger: "axis"
    },
    xAxis: {
      type: "category",
      boundarGap: false,
      // data: response.xaxis
      data: ["2023-1", "2023-2", "2023-3", "2023-4", "2023-5", "2023-6", "2023-7", "2023-8", "2023-9", "2023-10", "2023-11", "2023-12"]
    },
    yAxis: {
      name: "tCO₂e",
      type: "value"
    },
    series: [
      {
        name: "废气燃烧装置趋势",
        // data: response.panelList.filter(item => item.title == "UPW")[0].details.map(item => (item.value != null ? item.value : 0))
        //   ? response.panelList.filter(item => item.title == "UPW")[0].details.map(item => (item.value != null ? item.value : 0))
        //   : [0, 0, 0, 0, 0, 0, 0],
        data: [27.49, 27.49, 33.69, 47.46, 47.1, 44.4, 43.4, 44.27, 43.0, 47.8, 47.67, 50.15],
        type: "line"
      }
    ]
  };
};
getoptions();
</script>

<style scoped lang="scss">
.parent {
  float: left;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
</style>
